package com.real8.romemp.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

public class ShipBuildingPlace extends Place {
	public enum EMenuSelection {
		NONE, WARSHIPS, MERCHANTSHIPS, DO_NOTHING
	}

	private EMenuSelection menuOption;

	public ShipBuildingPlace() {
		this(EMenuSelection.NONE);
	}

	public ShipBuildingPlace(EMenuSelection menuOption) {
		this.menuOption = menuOption;
	}

	public EMenuSelection getMenuOption() {
		return menuOption;
	}

	public static class Tokenizer implements PlaceTokenizer<ShipBuildingPlace> {
		@Override
		public String getToken(ShipBuildingPlace place) {
			return place.getMenuOption().toString();
		}

		@Override
		public ShipBuildingPlace getPlace(String token) {
			// determine menuOption
			EMenuSelection menuOption = EMenuSelection.NONE;
			if (token.equalsIgnoreCase(EMenuSelection.WARSHIPS.toString())) {
				menuOption = EMenuSelection.WARSHIPS;
			} else if (token.equalsIgnoreCase(EMenuSelection.MERCHANTSHIPS.toString())) {
				menuOption = EMenuSelection.MERCHANTSHIPS;
			} else if (token.equalsIgnoreCase(EMenuSelection.DO_NOTHING
					.toString())) {
				menuOption = EMenuSelection.DO_NOTHING;
			}

			// end
			return new ShipBuildingPlace(menuOption);
		}
	}
}
